package com.cn.yang.servlet.news;

import com.alibaba.fastjson.JSONObject;
import com.cn.yang.model.news.NewsClassifyModel;
import com.cn.yang.model.production.ProductClassifyModel;
import com.cn.yang.service.NewsService;
import com.cn.yang.service.ProductService;
import com.cn.yang.service.impl.NewsServiceImpl;
import com.cn.yang.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/back/news/findNewsClassify")
public class NewsClassifyServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");

        NewsService service = new NewsServiceImpl();
        List<NewsClassifyModel> list = service.findClassify();

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("model",list);
        resp.getWriter().println(jsonObject);
    }
}
